S:=$(wildcard *.s)
C:=$(wildcard *.c)

CRSS_COMPILE :=arm-linux-gnueabihf-

CC:=$(CRSS_COMPILE)gcc
LD:=$(CRSS_COMPILE)ld
OBJCOPY:=$(CRSS_COMPILE)objcopy
OBJDUMP:=$(CRSS_COMPILE)objdump

NAME:= led
ALL:= $(NAME).bin

OBJS := $(S:%.s=%.o)
OBJS += $(C:%.c=%.o)

$(ALL):$(NAME)
	$(OBJCOPY) -O binary -S  $?.lef $@
	$(OBJDUMP) -D -m arm $?.lef > $?.dis

$(NAME):$(OBJS)
	$(LD) -Timx6u.lds $^ -o $@.lef

%.o:%.c
	$(CC) -Wall -nostdlib -c -O2 -o $@ $<

%.o:%.s
	$(CC) -Wall -nostdlib -c -O2 -o $@ $<

imx:$(ALL)
	./imxdownload $^ ./imx 

clear:
	rm -rf *.o $(ALL) $(NAME).elf $(NAME).dis  imx
